package com.zhu.androidsample.business;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.zhu.androidsample.R;
import com.zhu.androidsample.business.girls.GirlActivity;
import com.zhu.androidsample.business.phonelocation.PhoneLocationActivity;
import com.zhu.androidsample.common.BaseActivity;
import com.zhu.androidsample.util.FrescoUtil;

public class MainActivity extends BaseActivity implements View.OnClickListener {

    TextView result;
    Button btn_function1;
    Button btn_function2;
    SimpleDraweeView simpleDraweeView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn_function1 = (Button) findViewById(R.id.main_btn_function1);
        btn_function2 = (Button) findViewById(R.id.main_btn_function2);
        simpleDraweeView = (SimpleDraweeView) findViewById(R.id.main_img_gittest);

        init();
    }

    private void init() {
        btn_function1.setOnClickListener(this);
        btn_function2.setOnClickListener(this);
        Uri uri = Uri.parse("res://com.zhu.androidsimple/" + R.mipmap.git_test);
        simpleDraweeView.setAspectRatio(1);//设置图片长宽比例
        simpleDraweeView.setController(FrescoUtil.getGifDraweeController(uri));
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.main_btn_function1:
                Intent intent1 = getIntent();
                intent1.setClass(this, PhoneLocationActivity.class);
                startActivity(intent1);
                break;
            case R.id.main_btn_function2:
                Intent intent2 = getIntent();
                intent2.setClass(this, GirlActivity.class);
                startActivity(intent2);
                break;
        }
    }

}
